import { getParams } from '@/libs/util'
const USER_MAP = {
  admin: {
    'code': 200,
    'data': {
      'uid': 1,
      'avator': 'http://dladmin.hanyuit.net/upload/img/admin.png',
      'name': 'admin',
      'roletype': '1',
      'access': ['vip', 'admin'],
      'token': 'admin',
      'authKey': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1NDAwNDI2ODYsIm5iZiI6MTU0MDA0MjY4NiwiZXhwIjoxNTQwMDQ0MzMwLCJ1aWQiOjF9.DH-l33T4pm1EWWXcQudwqTZER9mU67cQOVs8GYVkQPY',
      'expire': 1540044330
    },
    'error': ''
  }
}

export const login = req => {
  console.log(req)
  req = JSON.parse(req.body)
  return USER_MAP[req.username]
}

export const getUserInfo = req => {
  const params = getParams(req.url)
  console.log(params)
  return USER_MAP[params.token]
}

export const logout = req => {
  return null
}
